<include file="header"/>
<body>
<div class="wraper">
	<div class="header">
        <span class="headertxt font-white">
            {BEESCRM:$act['act_name']}
        </span>
	</div>
	<div class="coupon">
		<div class="Coupons-background">
			<img src="/assets/coupon/images/bg.png" alt=""/>

			<div class="component text-center font-green flex">
				{BEESCRM:$coupon['title']}
			</div>
		</div>
	</div>
	<p class="text-center font-white font-16">有效期： {BEESCRM:$coupon['start_time']|date="Y-m-d",###} -
		{BEESCRM:$coupon['end_time']|date="Y-m-d",###}</p>
	<if condition="$record_info['is_use'] eq 1">
		<a href="javascript:void(0);" class="btn text-center">该优惠券已使用</a>
		<p class="Donation"></p>
		<elseif condition="$record_info['if_send'] eq 1"/>
			<a href="javascript:void(0);" class="btn text-center">该优惠券已转出</a>
			<p class="Donation"></p>
		<else/>
		<if condition="$coupon['coupon_type'] eq 0 && count($module_list) eq 1">
			<a href="{BEESCRM:$module_list[0]['url']}" class="btn text-center">立即使用</a>
			<else/>
			<a href="javascript:void(0);" class="btn text-center use_coupon">立即使用</a>
		</if>

		<if condition="$coupon['is_convert'] eq 1 && $record_info['if_send'] eq 0">
			<p class="font-white text-right Donation" id="share_present">转赠朋友&gt;&gt;</p>
			<else/>
			<p class="Donation"></p>
		</if>
	</if>


	<div class="padding-b">
		<div class="details">
			<div class="cover">
				<img src="/assets/coupon/images/cover.png" alt=""/>

				<div class="conver-txt">
					
					
					<p>使用场景：{BEESCRM:$use_module}</p>
				</div>
			</div>
			<a class="conver-txt flex" style="color:#2a2a2a"
			   href="/coupon/coupon/detail/coupon_id/{BEESCRM:$coupon['coupon_id']}/account_id/{BEESCRM:$account_id}">
				<span class="font-16">优惠券详情</span>
				<span class="width-10"><img src="/assets/coupon/images/back.png" alt=""/></span>
			</a>
		</div>
	</div>
	<div class="pop-box" style="display: none">
		<div class="pop-hint">
			<div class="flex">
				<span>请选择需要跳转的应用</span>
				<span class="close"><img src="/assets/coupon/images/close.png" alt=""/></span>
			</div>
			<div class='project'>
				<!-- <a href="#" class="item text-center visit margin-b10">充动</a>-->
				<if condition="$coupon['coupon_type'] eq 0">
					<volist name="module_list" id="vo">
						<a href="{BEESCRM:$vo['url']}" class="item text-center margin-b10">{BEESCRM:$vo.title}</a>
					</volist>
				</if>

				<if condition="$coupon['coupon_type'] eq 1">
					<volist name="module_list" id="vol">
						<a href="javascript:void(0);" data-module_id="{BEESCRM:$vol.module_id}" data-title="{BEESCRM:$vol.title}" class="item text-center margin-b10 module_id">{BEESCRM:$vol.title}</a>
					</volist>
				</if>

				<!--      <a href="#" class="item text-center margin-b10">在线订餐</a>
					  <a href="#" class="item text-center margin-b10">在线商城</a>
					  <a href="#" class="item text-center margin-b10">水费缴费</a>
					  <a href="#" class="item text-center margin-b10">电费缴费</a>
					  <a href="#" class="item text-center">智能洗衣</a>
					  <a href="#" class="item text-center">智能洗衣</a>-->
			</div>
		</div>
	</div>
	<input type="hidden" id="record_id" value="{BEESCRM:$record_id}">
	<input type="hidden" id="account_id" value="{BEESCRM:$account_id}">
</div>

<script src="/assets/coupon/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/ecs/js/jq.utils.js"></script>
<script src="/assets/bower_components/sweetalert/lib/sweet-alert.min.js"></script>
<script src="/assets/public/layermobile/layer.js"></script>
<link rel="stylesheet" href="/assets/bower_components/sweetalert/lib/sweet-alert.css?v={BEESCRM:$time}">
<!--分享-->
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<include file="share"/>
<script>
	var height = $(window).height();
	$('.wraper').css('minHeight', height);

	$('.project').on('click', '.item', function () {
		$(this).addClass('visit');
		$(this).siblings().removeClass('visit');
	});

	$('.use_coupon').click(function () {
		$('.pop-box').show();
	});

	$('.close').click(function () {
		$('.pop-box').hide();
	});

	$('.module_id').click(function(){
		var module_id = $(this).data('module_id');
		var title = $(this).data('title');
		$.confirm('确定将该优惠券应用到'+title+'模块吗？',todo);
		// 时长卡券使用
		function todo() {
			$('.pop-box').hide();
			var record_id = $('#record_id').val();
			var account_id = $('#account_id').val();
			$.ajax({
				url: "/coupon/coupon/useTimeCoupon",
				type: "post",
				dataType: 'json',
				data: {record_id: record_id, module_id: module_id,account_id:account_id},
				success: function (data) {
					if (data.status == 'S') {
						$.alert('success', data.message);
						window.location.href = data.url;
					} else {
						$.alert('error', data.message);
					}
				}
			});
		}
	});

	$(function(){
		//分享
		$('#share_present').on('click',function(){
			$.layeralert('点击右上角分享按钮转赠','background-color:#06c1ae; text-align:center;color:#fff; border:none;');
			url = "{BEESCRM::C('site_url').U('Coupon/coupon/index',array('data'=>base64_encode(json_encode(array('act_id' => $coupon['act_id'],'account_id' => $coupon['account_id'],'record_id' => $record_info['record_id'],'from_user_id'=>$record_info['user_id'])))))}";
			wx.ready(function(){
				doShare(1);
			});
		})
	})
</script>
</body>
</html>